import { defineConfig, loadEnv } from 'vite'
import vue from "@vitejs/plugin-vue";
const { resolve } = require('path')
import createVitePlugins from './vite/plugins'

// https://vitejs.dev/config/

export default defineConfig(({ mode, command }) => {
  const env = loadEnv(mode, process.cwd())
  const { VITE_APP_BASE } = env
  
  
  return {
    base: VITE_APP_BASE,
    // plugins: plugins,
    plugins:[
      vue(),
    ],
    resolve: {
      alias: {
        // '~': resolve(__dirname, './'),
        "@": resolve(__dirname, "./src"),
        "components": resolve(__dirname, "./src/components"),
        "styles": resolve(__dirname, "./src/page/styles"),
        "utils": resolve(__dirname, "./src/utils"),
      }
    },
    server: {
      port: 8080,
      proxy: {
        '/api': {
            // target: 'http://182.43.82.149:8088',
            target: 'http://localhost:8088',
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, '/api')
        },
        // historyApiFallback: {
        //   index: '/index.html' //与output的publicPath
        // },
      }
    },
  }
  
})

